﻿<Window x:Name="updateWindow" x:Class="UpdateApp.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:UpdateApp"
        xmlns:Metro="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
        xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
        Title="MainWindow" Height="153" Width="312" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" WindowStyle="None" AllowsTransparency="True" Loaded="updateWindow_Loaded">

    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <!--总颜色样式定义-->
                <ResourceDictionary Source="/Styles/Colors.xaml"/>
                <!--普通按钮样式定义-->
                <ResourceDictionary Source="/Styles/ButtonStyle.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Window.Resources>

    <Window.DataContext>
        <local:ViewModel/>
    </Window.DataContext>

    <Border BorderBrush="White" BorderThickness="1" CornerRadius="3" Background="{StaticResource bg}">
        <Grid  Background="{StaticResource bg}" >
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="MouseLeftButtonDown">
                    <i:InvokeCommandAction Command="{Binding DragCommand}" CommandParameter="{Binding ElementName=updateWindow}" />
                </i:EventTrigger>
            </i:Interaction.Triggers>
            <Grid.RowDefinitions>
                <RowDefinition Height="25" />
                <RowDefinition Height="*" />
                <RowDefinition Height="0" />
                <RowDefinition Height="0" />
            </Grid.RowDefinitions>
            <Grid Grid.Row="0" Background="{StaticResource tilebtn_bg}">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="3" />
                    <ColumnDefinition Width="20" />
                    <ColumnDefinition Width="3" />
                    <ColumnDefinition />
                    <ColumnDefinition Width="30" />
                    <ColumnDefinition Width="3" />
                </Grid.ColumnDefinitions>
                <Path Grid.Column="1" Height="14" Width="16" Fill="{StaticResource arrow}" Stretch="Fill" Data="F1 M 25,52L 51,52L 51,57L 25,57L 25,52 Z M 35,16L 41,16L 41,36.5L 49,27L 49,36.5L 38,49L 27,36.5L 27,27L 35,36.5L 35,16 Z "/>
                <TextBlock Text="自动升级" Grid.Column="3" Foreground="{StaticResource bg_text}" VerticalAlignment="Center" FontSize="14" Margin="0,4,196,3"/>
                <Button Width="30" Grid.Column="4" Height="20" Style="{StaticResource SysMinBtn}" VerticalAlignment="Top" Command="{Binding MinedCommand}" />
            </Grid>
            <Border x:Name="connStatus" Grid.Row="1" Background="{StaticResource bg}">
                <Grid>
                    <Metro:ProgressRing Margin="134,14,135,62" Height="50" IsActive="True" Foreground="{StaticResource bg_text}" Width="41"/>
                    <TextBlock HorizontalAlignment="Left" Foreground="{StaticResource bg_text}" Height="15" Margin="14,71,0,0" TextWrapping="Wrap" Text="准备状态：" VerticalAlignment="Top" Width="286" FontSize="14"/>
                    <TextBlock HorizontalAlignment="Left" Foreground="{StaticResource bg_text}" Height="15" Margin="14,90,0,0" TextWrapping="NoWrap" TextTrimming="WordEllipsis" Text=">>>" VerticalAlignment="Top" Width="286" FontSize="14">
                        <Run Text="{Binding ConnectStatus}"/>
                    </TextBlock>
                </Grid>
            </Border>
            <Border x:Name="receiveStatus" Grid.Row="2">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="20"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="20"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="5"/>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="5"/>
                    </Grid.RowDefinitions>
                    <TextBlock  Grid.Row="1" Grid.Column="1" Foreground="{StaticResource bg_text}" TextWrapping="NoWrap" TextTrimming="WordEllipsis" Text="文件：" VerticalAlignment="Center" FontSize="14">
                        <Run Text="{Binding FileName}" ToolTip="{Binding FileName}"/> 
                    </TextBlock>
                    <TextBlock Grid.Row="2" Grid.Column="1" Foreground="{StaticResource bg_text}" TextWrapping="NoWrap" TextTrimming="WordEllipsis" Text="已下载/总大小：" VerticalAlignment="Center" FontSize="14" >
                        <Run Text="{Binding FileSize}"/>
                    </TextBlock>
                    <TextBlock Grid.Row="3" Grid.Column="1" Foreground="{StaticResource bg_text}" TextWrapping="NoWrap" TextTrimming="WordEllipsis" Text="下载速度："  VerticalAlignment="Center" FontSize="14">
                        <Run Text="{Binding DownSpeed}"/>
                    </TextBlock>
                    <TextBlock Grid.Row="4" Grid.Column="1" Foreground="{StaticResource bg_text}" TextWrapping="NoWrap" Text="剩余时间：" VerticalAlignment="Center" FontSize="14">
                        <Run Text="{Binding LeftTime}"/>
                    </TextBlock>
                    <Metro:MetroProgressBar Grid.Row="5" Grid.Column="1" Value="{Binding PgBarValue}"  VerticalAlignment="Center" Width="280" Foreground="{StaticResource tilebtn_bg}" Height="17"/>
                    <TextBlock Grid.Row="5" Grid.Column="1" Foreground="{StaticResource bg_text}" Text="{Binding PgBarValue,StringFormat={}{0}%}" VerticalAlignment="Center" HorizontalAlignment="Center" />
                </Grid>
            </Border>
            <Border x:Name="updateStatus" Grid.Row="3" Background="{StaticResource bg}">
                <Grid>
                    <Metro:ProgressRing Margin="134,14,135,62" Height="50" IsActive="True" Foreground="{StaticResource bg_text}" Width="41"/>
                    <TextBlock HorizontalAlignment="Left" Foreground="{StaticResource bg_text}" Height="15" Margin="14,71,0,0" TextWrapping="Wrap" Text="更新状态：" VerticalAlignment="Top" Width="286" FontSize="14"/>
                    <TextBlock HorizontalAlignment="Left" Foreground="{StaticResource bg_text}" Height="15" Margin="14,90,0,0" TextWrapping="NoWrap" TextTrimming="WordEllipsis" Text=">>>" VerticalAlignment="Top" Width="286" FontSize="14">
                        <Run Text="{Binding UpdateStatus}"/>
                    </TextBlock>
                </Grid>
            </Border>
        </Grid>
    </Border>
</Window>
